package zhtt.demo02;

import org.apache.ibatis.type.JdbcType;
import org.apache.ibatis.type.TypeHandler;

import java.sql.CallableStatement;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * Created by mengxiaxia on 2017/4/26.
 */
public class TypeHandlerDemo implements TypeHandler {
    @Override
    public void setParameter(PreparedStatement ps, int i, Object parameter, JdbcType jdbcType) throws SQLException {
        System.out.println("\n处理String");
        ps.setString(i, (String) parameter);
    }

    @Override
    public Object getResult(ResultSet rs, String columnName) throws SQLException {
        System.out.println("\n处理String");
        return rs.getString(columnName);
    }

    @Override
    public Object getResult(ResultSet rs, int columnIndex) throws SQLException {
        System.out.println("\n处理String");
        return rs.getString(columnIndex);
    }

    @Override
    public Object getResult(CallableStatement cs, int columnIndex) throws SQLException {
        System.out.println("\n处理String");
        return cs.getString(columnIndex);
    }
}
